import java.util.List;
import java.util.Map;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import util.Db;

public class AppMain {

	public static void main(String[] args) throws Exception {
		QueryRunner qr = new QueryRunner(Db.ds);
		String sql = "select id,content from resource ";
		List<Map<String, Object>> ls = qr.query(sql, new MapListHandler());
		for (Map<String, Object> m : ls) {
			int id = (Integer) m.get("id");
			String content = (String) m.get("content");
			
			if (content != null) {
				Document doc = Jsoup.parse(content);
				
				System.out.println(content);
				
				/*
				Elements es = doc.getElementsByAttributeValueStarting("src", "/ctimg/");
				System.out.println(es);
				es.remove();
				String newcontent=doc.body().html();
				
				newcontent=StringUtils.remove(newcontent, "class=\"iptcom-title\"");
				newcontent=StringUtils.remove(newcontent, "<span class=\"post_origin_img\"></span>");
				newcontent=StringUtils.remove(newcontent, "class=\"inner_content\"");
				*/
				System.out.println("------------");
				
				//qr.update("update resource set content=? where id =?" ,newcontent,id );
				
				// System.out.println(newcontent);
				
				
			}
			
			
			
		}

	}

}
